package com.zhengke.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhengke.dao.ShippingListDao;
import com.zhengke.pojo.ShippingEntity;
import com.zhengke.service.ShippingListDaoService;

@Service
public class ShippingListDaoServiceImpl implements ShippingListDaoService {
	
	@Autowired
	ShippingListDao shippingListDao;

	@Override
	public List<ShippingEntity> getShippingList(Map<String, Object> messageMap) {
		
		List<Map<String, Object>> shippingList = shippingListDao.getShippingList(messageMap);
		
		//创建返回到前台数据的list集合
		List<ShippingEntity> shippingListReList = new ArrayList<ShippingEntity>();
		//遍历添加数据
		for(Map<String, Object> map : shippingList) {
			ShippingEntity shipping = new ShippingEntity();
			shipping.setUser_id(map.get("user_id")+"");
			shipping.setReceipt_method(map.get("receipt_method")+"");
			shipping.setGoods_amount(map.get("goods_amount")+"");
			shipping.setUser_card_number(map.get("user_card_number")+"");
			shipping.setUser_name(map.get("user_name")+"");
			shipping.setReceiver_phone(map.get("receiver_phone")+"");
			shipping.setReceiver_address(map.get("receiver_address")+"");
			shipping.setOrder_sn(map.get("order_sn")+"");
			String dateString = (String) map.get("add_time");
			shipping.setAdd_time(dateString);
			shipping.setOrder_state(map.get("order_state")+"");
			shipping.setGoods_name(map.get("goods_name")+"");
			shipping.setGoods_num(map.get("goods_num")+"");
			shipping.setSpecifications(map.get("specifications")+"");
			shipping.setGoods_type(map.get("goods_type")+"");
			shippingListReList.add(shipping);
		}
		System.out.println(shippingListReList);
		
		return shippingListReList;
	}

	@Override
	public int updateOrderMethod(String id) {
		
		return shippingListDao.updateOrderMethod(id);
	}

	@Override
	public String querryOrderTotal() {
		
		return shippingListDao.querryOrderTotal();
	}
}
